import $api from "./request.js"

//获取用户认养列表信息
export const getFosterList = ()=>$api({
	url:"/foster/ryBase/getFosterList",
	method:"GET",
})
//获取所有认养地信息
export const findAllBase = ()=>$api({
	url:"/foster/ryBase/findAllBase",
	method:"GET",
})
//根据认养地id获取该地地块信息
export const findLandByBaseId = (id)=>$api({
	url:'/foster/ryBase/findLandByBaseId?baseId='+id,
	method:"GET",
})
//根据地块id计算地块价格
export const findRentsByLandS = (ids)=>$api({
	url:'/foster/ryTenancy/findRentsByLandS',
	data:ids,
})
//base64转换为图片
export const uploadBase64Oss = (base64)=>$api({
	url:'/foster/file/uploadBase64Server',
	data:base64,
	header:{
		'Content-Type':'application/x-www-form-urlencoded'
	}
})
//保存租地表单配置
export const insertTenancy = (data,token)=>$api({
	url:'/foster/ryTenancy/insertTenancy',
	data,
})
//微信登录
export const weiXinLogin = (code) =>$api({
	url:'/foster/user/login?code='+code
})
//根据租地id获取租地订单信息
export const findTenancyOrderById = (query)=>$api({
	url:'/foster/ryTenancy/findTenancyOrderById?tenancyId='+query,
	method:"GET",
})
//根据地块id和状态查询地块信息
export const findLandMsgByLandId = (query)=>$api({
	url:'/foster/ryLand/findLandMsgByLandId?'+query,
	method:'GET',
})
//根据地块id和（如果有）地块任务id查询地块详情
export const findLandMsgByLandMsgId = (query)=>$api({
	url:'/foster/ryLand/findLandMsgByLandMsgId?'+query,
	method:"GET"
})
//根据地块id获取该地块种植种类
export const findLandGrowVariety = (query)=>$api({
	url:'/foster/ryLand/findLandGrowVariety?'+query,
	method:'GET'
})
//种植
export const landGrow = (data)=>$api({
	url:'/foster/ryLand/landGrow',
	data
})
//新增任务
export const addTask = (data)=>$api({
	url:'/foster/ryTask/addTask',
	data
})
//根据品种id获取任务类型
export const findFarmByVarietyId = (query)=>$api({
	url:'/foster/ryLand/findFarmByVarietyId?'+query,
	method:'GET'
})
//查询所有施肥投入品的道具
export const allVariableInputDetail = ()=>$api({
	url:'/foster/ryLand/allVariableInputDetail',
	method:"GET"
})
//通过任务类型查询该地块任务次数
/**
 * @param landMsgId {string}
 * @param taskType {string}
*/
export const findTaskNumberByTaskType = (query)=>$api({
	url:'/foster/ryTask/findTaskNumberByTaskType?'+query,
	method:'GET'
})
/**
 * @description 通过小地块id查询当前小地块任务列表
 * @@param {string} landMsgId 
*/
export const taskList = (query)=>$api({
	url:'/foster/ryTask/taskList?'+query,
	method:'GET'
})
/**
 * @description 通过任务id获取任务详情
 * @param {string} id
**/
export const findTaskDetailById = (query)=>$api({
	url:'/foster/ryTask/findTaskDetailById?'+query,
	method:'GET'
})
/**
 * @description 查询当前用户的所有地址
*/
export const getUserAllAddress = ()=>$api({
	url:'/foster/ryUserAddress/page',
	method:"GET"
})

/**
 * @description 获取当前账号邮寄信息
   @param landMsgId {string}
*/
export const findMailGoodsInfo = (query)=>$api({
	url:'/foster/ryLand/findMailGoodsInfo?'+query,
	method:'GET'
})

/**
 * @description 发送邮寄请求
   @param landMsgId {string}
   @param addressId {string}
*/
export const mailGoods = (query)=>$api({
	url:'/foster/ryLand/mailGoods?'+query,
})

/**
 * @description 新增/修改收货地址
*/
export const addOrEditAddress = data =>$api({
	url:'/foster/ryUserAddress',
	data
})
/**
 * @description 删除收货地址
*/
export const delAddress = query =>$api({
	url:'/foster/ryUserAddress/'+query,
	method:"DELETE"
})
/**
 * @description 支付接口
*/
export const pay = (query)=>$api({
	url:'/foster/wxPay/pay?orderNo='+query,
})

/**
 * @description 查询用户合同列表
 */
export const findUserContract = ()=>$api({
	url:'/foster/ryTenancy/findUserContract',
	method:"GET"
})

/**
 * @description 根据id获取合同详情
 * @param {string}  = [tenancyId] 
*/
export const findContract = query=>$api({
	url:'/foster/ryTenancy/findContract?'+query,
	method:'GET'
})
/**
 * @description 根据地块id获取天气
 * @param {string}  = [landId] 
*/
export const findWeatherAndCameraDataByLandId = query =>$api({
	url:'/foster/ryLand/findWeatherAndCameraDataByLandId?'+query,
	method:"GET"
})
/**
 * @description 获取订单列表
 * @param {number}  = [pageNum] 
 * @param {number}  = [pageSize] 
 * @param {number}  = [state]
*/
export const findUserOrderInfo = query =>$api({
	url:'/foster/ryTenancy/findUserOrderInfo?'+query,
	method:"GET"
})




////** 上传图片接口 **////
export const uploadImage = (data)=>{
	let promise =  new Promise((reslove,reject)=>{
		uni.uploadFile({
			url:'https://grove.cpzsyun.com:82/ryapi/foster/file/uploadImg',
			filePath:data,
			name:"file",
			header:{
				'Content-Type':'multipart/form-data; boundary=--------------------------847724091307819899995715',
			},
			success: (res) => {
				reslove(res)
			},
			fail: (err) => {
				reject(err)
			}
		})
	})
	return promise
}




////**  操作端接口  **////
/**
 * @description 操作端登录
 * @param {object}:{
			 name:{string}
			 pwd:{string}
		   } 
*/
export const operatorLogin = (data)=>$api({
	url:'/foster/ryOperateAccount/login',
	data
})
// 操作端根据状态获取任务列表
export const findTaskByUserId = (query)=>$api({
	url:'/foster/opRyTask/findTaskByUserId?'+query,
	method:'GET',
	header:{
		token:uni.getStorageSync("operatorAccount").token
	}
})
//根据地块id和任务id获取该地块的指定任务的任务详情
export const operatorFindTaskDetailById = (query)=>$api({
	url:'/foster/opRyTask/findTaskDetailById?'+query,
	method:'GET',
	header:{
		token:uni.getStorageSync("operatorAccount").token
	}
})
//操作端处理任务
export const disposeTask = (data)=>$api({
	url:'/foster/opRyTask/disposeTask',
	data,
	header:{
		token:uni.getStorageSync("operatorAccount").token
	}
})
//操作端扫描二维码获取地块id查询详情
export const findLandMsgByScanLandId = query =>$api({
	url:'/foster/opRyTask/findLandMsgByScanLandId?'+query,
	method:'GET',
	header:{
		token:uni.getStorageSync("operatorAccount").token
	}
})
//操作端根据地块id获取当前品种列表
export const findVarietyByLandId = query =>$api({
	url:'/foster/opRyTask/findVarietyByLandId?'+query,
	method:'GET',
	header:{
		token:uni.getStorageSync("operatorAccount").token
	}
})
//操作端根据品种类型获取任务类型
export const findOperatorByVarietyName = query =>$api({
	url:'/foster/opRyTask/findOperatorByVarietyName?'+query,
	method:'GET',
	header:{
		token:uni.getStorageSync("operatorAccount").token
	}
})
//操作端根据地块id获取地块坐标
export const opFindTaskDetailById = (query)=>$api({
	url:'/foster/opRyTask/findTaskDetailById?'+query,
	method:'GET',
	header:{
		token:uni.getStorageSync("operatorAccount").token
	}
})
//操作端获取任务完成次数
export const findAccomplishByLandMsgIdAndTaskType = (query)=>$api({
	url:'/foster/opRyTask/findAccomplishByLandMsgIdAndTaskType?'+query,
	method:'GET',
	header:{
		token:uni.getStorageSync("operatorAccount").token
	}
})
//管理员新增任务
export const addOperatorTask = (data)=>$api({
	url:'/foster/opRyTask/addOperatorTask',
	data,
	header:{
		token:uni.getStorageSync("operatorAccount").token
	}
})
//根据当前管理员账号查询可操作的基地信息或可操作基地下的地块信息
export const findOperatorBaseAndLand = query =>$api({
	url:'/foster/opRyTask/findOperatorBaseAndLand?'+query,
	method:"GET",
	header:{
		token:uni.getStorageSync("operatorAccount").token
	}
})
//根据地块id查询地图坐标与地块绑定的信息
export const findLandInfoByLandId = query => $api({
	url:'/foster/opRyTask/findLandInfoByLandId?'+query,
	method:'GET',
	header:{
		token:uni.getStorageSync("operatorAccount").token
	}
})